package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.OceanTemplate;
import com.egao.orderB.service.OceanTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 *
 * 海运费用模板
 * @author : Doman
 * @date : 2021-10-19 14:30:21
 * @version ：1.0
 */

@Api(tags = "海运费用模板")
@RestController
@RequestMapping("/api/orderB/oceanTemplate")
public class OceanTemplateController extends BaseController {

	@Autowired
	private OceanTemplateService oceanTemplateService;

	/**
	 * 分页查询列表
	 */
//	@PreAuthorize("hasAuthority('orderB:oceanTemplate:list')")
  @ApiOperation(value ="分页查询海运费用模板",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    " \n\n\n" +
    "返回的结果:\n" +
    "id:id\n" +
    "customer:船公司名称\n" +
    "boxType:箱型\n" +
    "portOfDestination:目的港\n" +
    "createTime:创建时间\n" +
    "createUser:创建人\n" +
    "updateTime:更新时间\n" +
    "updateUser:更新人\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/list")
  public JsonResult page(PageResult2<T> page, OceanTemplate oceanTemplate) throws Exception{
    return oceanTemplateService.list(page, oceanTemplate, getLoginUser());
  }

  /**
   * 查询全部海运费用模板
   */
//  @PreAuthorize("hasAuthority('orderB:oceanTemplate:list')")
  @ApiOperation("查询全部海运费用模板")
  @PostMapping("/listAll")
  public JsonResult list(OceanTemplate oceanTemplate){
    return oceanTemplateService.list(oceanTemplate, getLoginUser());
  }

  /**
   * 根据id查询海运费用模板
   */
//  @PreAuthorize("hasAuthority('orderB:oceanTemplate:list')")
  @ApiOperation("根据id查询海运费用模板")
  @PostMapping("/get")
  public JsonResult get(OceanTemplate oceanTemplate) {
    return oceanTemplateService.getById(oceanTemplate);
  }


  /**
   * 添加海运费用模板
   */
//  @PreAuthorize("hasAuthority('orderB:oceanTemplate:save')")
  @OperLog(value = "海运费用模板", desc = "添加", param = false, result = true)
  @ApiOperation(value ="添加海运费用模板",notes = "" +
    "customer:船公司名称\n" +
    "boxType:箱型\n" +
    "portOfDestination:目的港\n" +
    "",httpMethod = "POST")
  @PostMapping("/save")
  public JsonResult save(Model model, OceanTemplate oceanTemplate) {
    return oceanTemplateService.save(oceanTemplate, getLoginUser());
  }

  /**
   * 修改海运费用模板
   */
//  @PreAuthorize("hasAuthority('orderB:oceanTemplate:update')")
  @OperLog(value = "海运费用模板", desc = "修改", param = false, result = true)
  @ApiOperation(value ="修改海运费用模板",notes = "" +
    "id:id\n" +
    "customer:船公司名称\n" +
    "boxType:箱型\n" +
    "portOfDestination:目的港\n" +
    "",httpMethod = "POST")
  @PostMapping("/update")
  public JsonResult update(Model model, OceanTemplate oceanTemplate) {
    return oceanTemplateService.update(oceanTemplate, getLoginUser());
  }

  /**
   * 删除海运费用模板
   */
//  @PreAuthorize("hasAuthority('orderB:oceanTemplate:remove')")
  @OperLog(value = "海运费用模板", desc = "删除", result = true)
  @ApiOperation("删除海运费用模板")
  @PostMapping("/remove")
  public JsonResult remove(OceanTemplate oceanTemplate ) {
    return oceanTemplateService.remove(oceanTemplate, getLoginUser());
  }

}
